package org.cloud.admin.auth.holder;

import org.cloud.admin.auth.vo.LoginedUserVo;

/**
 * 线程级别缓存常量
 * @author wangyuan
 * @since 2019年6月5日 下午6:11:52
 *
 */
public class AppHolder {

	private static ThreadLocal<LoginedUserVo> loginedUser = new ThreadLocal<>();
	
	public static void setLoginedUser(LoginedUserVo user) {
		loginedUser.set(user);
	}
	
	public static LoginedUserVo getLoginedUser() {
		return loginedUser.get();
	}
	
	public static Long getLoginedUserId() {
		LoginedUserVo user = getLoginedUser();
		if(user != null) {
			return user.getId();
		} else {
			return null;
		}
	}
	
}
